package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShoppingCartMapper {


    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> list(Long userId);


    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void add(ShoppingCart shoppingCart);

    ShoppingCart findUidAndDidOrSid(ShoppingCart shoppingCart);

    @Update("update shopping_cart set number=#{number} where id =#{id}")
    void update(ShoppingCart shoppingCart1);

    @Delete("delete from shopping_cart where user_id=#{userId}")
    void clean(@Param("userId") Long userId);

    ShoppingCart findByDishId(@Param("dishId") String dishId);

    void deleteByDishId(@Param("dishId") String dishId);

    ShoppingCart findBySetmealId(@Param("setmealId") String setmealId);

    void deleteBySetmealId(@Param("setmealId") String setmealId);
}
